package com.shop.loan.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.Readonly;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.*;
import xyz.erupt.jpa.model.BaseModel;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.util.Date;

@Erupt(
        name = "意见反馈",
        orderBy = "Feedback.id desc",
        power = @Power(add = false, delete = false)
)
@Table(name = "s_feedback")
@Entity
@ApiModel("意见反馈")
@Getter
@Setter
public class Feedback extends BaseModel {

    @EruptField(
            views = @View(title = "反馈类型"),
            edit = @Edit(title = "反馈类型", type = EditType.CHOICE, search = @Search,
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "产品问题", value = "1"),
                                    @VL(label = "其他问题", value = "9"),
                            })
            )
    )
    @ApiModelProperty(name = "type", value = "反馈类型", dataType = "int", example = "1")
    private Integer type;


    @EruptField(
            views = @View(title = "内容"),
            edit = @Edit(title = "内容", notNull = true)
    )
    @ApiModelProperty(name = "content", value = "内容", dataType = "string", example = "1")
    private String content;


    @EruptField(
            views = @View(title = "状态"),
            edit = @Edit(
                    title = "状态",
                    search = @Search,
                    type = EditType.BOOLEAN,
                    boolType = @BoolType(
                            trueText = "已处理",
                            falseText = "未处理"
                    )
            )
    )
    @ApiModelProperty(name = "status", value = "状态", dataType = "int", example = "1")
    private Boolean status;


    @EruptField(
            views = @View(title = "备注"),
            edit = @Edit(title = "备注")
    )
    @ApiModelProperty(name = "remark", value = "内容", dataType = "string", example = "1")
    private String remark;

    @ManyToOne
    @EruptField(
            views = @View(title = "反馈人", column = "name"),
            edit = @Edit(
                    title = "反馈人",
                    search = @Search(vague = true),
                    type = EditType.REFERENCE_TREE
            )
    )
    @JoinColumn(name = "rental_user_id")
    private User rentalUser;


    @EruptField(
            views = @View(title = "反馈时间"),
            edit = @Edit(title = "反馈时间",
                    readonly = @Readonly,
                    dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    private Date createTime;
}
